package org.westboy.controller;

import de.felixroske.jfxsupport.FXMLController;
import javafx.fxml.FXML;
import javafx.scene.control.TextField;
import org.apache.commons.lang3.StringUtils;
import org.westboy.App;
import org.westboy.common.base.BaseController;
import org.westboy.view.IndexView;

@FXMLController
public class LoginController extends BaseController{

    @FXML
    private TextField loginName;

    @FXML
    private TextField passWord;

    @FXML
    private void doLogin(){

        if(StringUtils.isBlank(loginName.getText())){
            loginName.setFocusTraversable(true);
            showErrorAlert("登录账号不能为空！");
        }
        if(StringUtils.isBlank(passWord.getText())){
            loginName.setFocusTraversable(true);
            showErrorAlert("登录密码不能为空！");
        }
        if (loginName.getText().equals("admin")&&passWord.getText().equals("12356789")){
            App.getStage().close();
            App.showView(IndexView.class);
        }else{
            showErrorAlert("账号密码错误！");
        }

    }

    @Override
    protected void initialize() {

    }
}
